package com.xbongbong.pro.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

import java.util.Objects;

/**
 * @author haibin.zhang
 * @version v1.0
 * @date 2019/6/20 14:41
 * @since v1.0
 */
@Getter
public enum RepairExplainEnum {
    REPAIR(1, "enum.repairExplain.name.repair"),
    ADD(2, "enum.repairExplain.name.add"),
    DEL(3, "enum.repairExplain.name.del"),
    UNKONW(404, "enum.repairExplain.name.unkonw"),
    ;

    RepairExplainEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    private Integer code;
    private String name;

    public static RepairExplainEnum getByCode(Integer operate) {
        for (RepairExplainEnum repairExplainEnum : RepairExplainEnum.values()){
            if (Objects.equals(operate,repairExplainEnum.getCode())){
                return repairExplainEnum;
            }
        }
        return UNKONW;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }
}
